
#include "test_at.h"
#include "usart.h"

t_at_t*SLM332;

uint8_t send_data(void *Ptx,uint8_t *dataBuf, uint32_t bufLen){

/*HW--huart1*/
  HAL_UART_Transmit_DMA(&huart5, dataBuf,bufLen);
  return 0;
}



/**下面是吧接收数据丢入at对象**/
/*这个过程是串口接收
t_at_t*test;
void huart1_rx_handle_inter(uint8_t *dataBuf, uint32_t bufLen)//w伪串口接收中断入口
{
   if(idle_flag==1)
   {
      dataBuf==hwhuart;
      bufLen==hwhuart;
      t_at_rePushSet(test,dataBuf,bufLen);
    }
}

*/
/**还需要实现AT 1MS 计数*
 * 将如下函数丢入1MS中断就可
 * void t_at_1ms_cycle(void);
*/
uint8_t str(void *Ptx,uint8_t *dataBuf, uint8_t *cmd_UrcString){

  //printf("handle callback OK  . &s",dataBuf);
	printf("handle callback OK  . %s\n",cmd_UrcString);
  
  return 0;
}
EventGroupHandle_t osEvent = NULL;

void test_t_at(void)
{
	
  osEvent = pvPortMalloc(sizeof(EventGroupHandle_t));
  if(osEvent == NULL)
  {
    return;
  }
  //创建一个AT对象  SLM332   10ms超时  重发1次
  SLM332=t_at_create(send_data,NULL,100,1);
   
	t_at_os_create(SLM332,osEvent,t_at_os_init_t,t_at_os_lock_t,t_at_os_unlock_t);
  //发送AT指令
  t_at_cmd_send(SLM332,"AT+CSQ\r\n","CSQ",str,1000,1);
	
	t_at_cmd_send(SLM332,"AT+CSQ1111\r\n","CSQ",str,1000,1);
	
	t_at_cmd_send(SLM332,"AT+CSQqqqqq\r\n","CSQ",str,1000,1);
	
	t_at_urc_callback_set(SLM332,str);
  
}


